import { mockVersions } from '../../test/utils/mockVersions';

import { renderHbsTemplate } from './renderHbsTemplate';

/**
 * @group node
 */
describe('renderHbsTemplate.ts', () => {
  test('should render given template w/ data while injecting header', () => {
    // mocking
    const { versions, restore } = mockVersions();

    // executing
    const template = `{{header}}\nHello, {{project}}!`;
    const data = { project: 'Fuel' };
    const rendered = renderHbsTemplate({ template, data, versions });

    // validating
    restore();

    expect(rendered).toMatch(/Autogenerated file/g);
    expect(rendered).toMatch(new RegExp(`Fuels version: ${versions.FUELS}`, 'gm'));
    expect(rendered).toMatch(new RegExp(`Forc version: ${versions.FORC}`, 'gm'));
    expect(rendered).toMatch(new RegExp(`Fuel-Core version: ${versions.FUEL_CORE}`, 'gm'));

    expect(rendered).toMatch(/Hello, Fuel!/g);
  });
});
